package com.boot.mgt.controller.web

import com.boot.core.result.ResultTo
import com.boot.mgt.model.TaAcdFile2018
import com.boot.mgt.service.TaAcdFile2018Service
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import java.text.SimpleDateFormat

/**
 * 区域管理管理
 */
@RestController
@RequestMapping("/admin/history")
class TaHistroyAccidentController {

    @Autowired
    private lateinit var taAcdFile2018Service: TaAcdFile2018Service

    @GetMapping("/list")
    fun list(page_index: Int?, page_size:Int?, has_marked:Int?, begin_date:String?, end_date:String?, sglx:Int?): ResultTo {
        var beginDate =  SimpleDateFormat("yyyy-MM-dd").parse(begin_date?:"2018-01-01")
        var endDate =SimpleDateFormat("yyyy-MM-dd").parse(end_date?:"2019-01-01")
        return taAcdFile2018Service.list(page_index?:1, page_size?:20, has_marked?:0, beginDate, endDate, sglx?:-1)
    }

    @GetMapping("/detail")
    fun list(id:Int): ResultTo {
        return taAcdFile2018Service.detail(id)
    }

    @PostMapping("/set_coordinates")
    fun setCoordinates(acd_file_2018_id:Int,latitude:String, longitude:String): ResultTo {
        return taAcdFile2018Service.setCoordinates(acd_file_2018_id, latitude, longitude)
    }
}